<extend name="desktop_default/template/user/base_user" />
<block name="area_header">
    <link rel="stylesheet" href="__CSS__/user/favorite/sp/style.css">
</block>

<block name="area_top">

</block>
<block name="user_top">

</block>
<block name="main_content">
    <div class="favorite-sp">
        <div class="user-tab">
            <a class="selected" href="{:U('mengwu/user/favorite')}">商品收藏</a>
            <a href="{:U('mengwu/user/favorite/t/post')}">帖子收藏</a>
        </div>
        <empty name="sp_list">
            <div class="empty-list">还没有任何收藏的商品哦~</div>
        </empty>
        <notempty name="sp_list">
            <div class="sp-list">
                <ul>
                    <volist name="sp_list" id="vo">
                        <li>
                            <a class="sp-li" href="{:U('mengwu/spdetail/index',array('id'=>$vo['id']))}" target="_blank"><a class="sp-del" data-pid="{$vo.id}"><i class="icon-del"></i>删除</a></a>
                            <div class="sp-img"><img src="{$vo.img}"></div>
                            <div class="caption">
                                <span>{$vo.name}</span>
                            </div>
                            <div class="price">
                                <em class="rmb">￥</em></small>{$vo.price}
                            </div>
                        </li>
                    </volist>
                </ul>
            </div>
            {$show}
        </notempty>
    </div>

</block>
<block name="area_footer">
    <script type="text/javascript">
        $(".sp-list li").bind({
            'mouseover':function(){
                $(this).find('.sp-del').eq(0).animate({bottom:0},'fast');
            },
            'mouseleave':function(){
                $(this).find('.sp-del').eq(0).animate({bottom:-30+'px'},'fast');
            }
        });
        $(".sp-del").click(function(){
            var url = getBaseUrl() + '/mengwu/mengwuApi/product_favorites';
            var data = {
                pid: $(this).attr('data-pid'),
                value: 0
            };
            var _hide = antd.message.loading('正在删除...',0);
            _post(url,jQuery.param(data),{data_back: function(data){
                if(data.status){
                    _hide();
                    antd.message.success('删除成功');
                    window.location.reload();
                }else{
                    if(typeof data.info.redirect !="undefined"){
                        antd.message.error(data.info.info);
                        setTimeout(function(){
                            window.location.href = data.info.redirect;
                        },1000);
                    }else{
                        antd.message.error('删除失败！');
                    }
                }
            }});
        });
    </script>

</block>
